package com.onlyphoto.onlymall.mvp.presenter

import android.content.Context
import com.onlyphoto.onlymall.base.BaseNetworkResponse
import com.onlyphoto.onlymall.base.BaseObserver

import com.onlyphoto.onlymall.mvp.contract.CLogin
import com.onlyphoto.onlymall.mvp.model.MLoginImpl
import com.onlyphoto.onlymall.base.BasePresenter
import com.onlyphoto.onlymall.bean.response.UserInfoBean


class PLoginImpl(mContext: Context, mView: CLogin.IVLogin) : BasePresenter<CLogin.IVLogin, MLoginImpl>(mContext, mView, MLoginImpl()), CLogin.IPLogin {
    override fun wxLogin(userInfo: String) {
        mModel.loginByWx(userInfo, object : BaseObserver<UserInfoBean>(mContext.get()){
            override fun onSuccess(data: UserInfoBean?, msg: String?) {
                mView.wxLoginSuccess(data!!)
            }

            override fun onCodeError(t: BaseNetworkResponse<UserInfoBean>?) {
                mView.showToast(t?.msg!!)
            }

            override fun onFailure(e: Throwable?) {
            }

            override fun onRequestStart() {
                mView.showLoading()
            }

            override fun onFinally() {
                mView.hideLoading()
            }

        })
    }
}
